package mk.gamemap.model
{
	public class MapData
	{
		public var id:int;
		public var x:int;
		public var y:int;
		public var type_arr:Array;
		private var xml:XML
		public function MapData(xml:XML)
		{
			this.xml=xml;
			init(xml)
		}
		
		public function getSpriteXml():XML{
			return  XML(xml.sprites);
		}
		
		private function init(xml:XML):void{
			var arr2d:Array=xmlToArray(xml.map_data)
			type_arr = new Array();
			var numRows : int = 0;
			var numCols : int = 0;
			
			//	parseDefinition(xml.TileData);
			numRows= arr2d.length;
			numCols =arr2d[0].length;
			
			for (var i:uint = 0; i <numCols; i++ ) {
				type_arr[i]=[]
				for (var j : int = 0;j < numRows; j++) {
					
					type_arr[i][j]=arr2d[j][i]
				}
			}
			
		}
		
		private function xmlToArray(xml):Array{
			var arr:Array = new Array();
			var numRows : int = 0;
			var numCols : int = 0;
			
			
			numRows= xml.children().length();
			numCols =xml.children()[0].length();
			
			for (var i:uint = 0; i <numRows; i++ ) {
				arr[i]=xml.children()[i].split(",");
				
			}
			
			return arr;
		}
	}
}